#====# Appendix H: Robustness to estimation choices #====#

# Load libraries and set defaults ----
library(bizdays)
library(modelsummary)
library(tinytable)
library(tidyverse)
library(tidylog, warn.conflicts = FALSE)
source("aux/event_function.R")

# prepare business calendar:
business_calendar <- create.calendar('biz_calendar', weekdays = c('saturday','sunday'))

# Import data ----
stocks <- read_rds("data_out/stocks_analysis.rds") # main analysis dataset

# Table H.1: Varying CV folds of LASSO market models (10 folds) ----
est <- return_daily_avg(data = stocks, abn_ret = "abn_chg_30d10f", cum_abn_ret = "car_30d10f", stratum = "FCPA_sample") %>%
  mutate(date = format(date, format = "%a, %b %d %Y")) %>%
  rename("term" = "date")

mod_ar1 <- list(tidy = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car1 <- list(tidy = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar0 <- list(tidy = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car0 <- list(tidy = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar_diff <- list(tidy = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      select(-FCPA_sample, -dv),
                    glance = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      filter(term == "Mon, Feb 10 2025") %>%
                      select(N) %>%
                      rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car_diff <- list(tidy = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       select(-FCPA_sample, -dv),
                     glance = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       filter(term == "Mon, Feb 10 2025") %>%
                       select(N) %>%
                       rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

modelsummary(list("(1) \\textsc{ar}" = mod_ar1,
                  "(2) \\textsc{car}" = mod_car1,
                  "(3) \\textsc{ar}" = mod_ar0,
                  "(4) \\textsc{car}" = mod_car0,
                  "(5) \\textsc{ar}" = mod_ar_diff,
                  "(6) \\textsc{car}" = mod_car_diff),
             # statistic = "[{conf.low}, {conf.high}]",
             notes = paste0("Average \\textsc{ar} and \\textsc{car} to past FCPA targets and matched placebo firms ",
                            "per day. Standard errors of the mean reported in parentheses. P-values from a two-tailed test ",
                            "of difference from zero for the average against a standard normal distribution. ",
                            "Estimation window starts 30 days and ends 5 days before FCPA Executive Order. Market models estimated using ",
                            "the LASSO and individual S\\&P 500 constituents as predictors, selected using 10-fold cross validation. ",
                            "Columns 5 and 6 report the difference in means, respectively, between averages in columns 1 and 3, and those in columns 2 and 4.",
                            collapse = ""),
             title = "Varying CV folds of LASSO market models (10 folds) \\label{tab:rob_10f}",
             stars = c("*" = 0.05), 
             escape = FALSE) %>%
  group_tt(j = list("Past FCPA targets" = 2:3,
                    "Non-FCPA targets" = 4:5,
                    "Difference-in-means" = 6:7)) %>%
  group_tt(i = list("Pre-event:" = 1,
                    "Post-event:" = 11)) %>%
  style_tt(i = 21, line_color = "white", line_width = 0.1, line = "t") %>%
  style_tt(i = 22, line_color = "black", line_width = 0.05, line = "b") %>%
  theme_tt("resize", width = .9) %>%
  theme_tt("placement", latex_float = "!htbp") %>%
  save_tt("tables/table_H1.html", overwrite = TRUE)

# Table H.2: Varying CV folds of LASSO market models (5 folds) ----
est <- return_daily_avg(data = stocks, abn_ret = "abn_chg_30d5f", cum_abn_ret = "car_30d5f", stratum = "FCPA_sample") %>%
  mutate(date = format(date, format = "%a, %b %d %Y")) %>%
  rename("term" = "date")

mod_ar1 <- list(tidy = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car1 <- list(tidy = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar0 <- list(tidy = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car0 <- list(tidy = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar_diff <- list(tidy = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      select(-FCPA_sample, -dv),
                    glance = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      filter(term == "Mon, Feb 10 2025") %>%
                      select(N) %>%
                      rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car_diff <- list(tidy = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       select(-FCPA_sample, -dv),
                     glance = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       filter(term == "Mon, Feb 10 2025") %>%
                       select(N) %>%
                       rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

modelsummary(list("(1) \\textsc{ar}" = mod_ar1,
                  "(2) \\textsc{car}" = mod_car1,
                  "(3) \\textsc{ar}" = mod_ar0,
                  "(4) \\textsc{car}" = mod_car0,
                  "(5) \\textsc{ar}" = mod_ar_diff,
                  "(6) \\textsc{car}" = mod_car_diff),
             # statistic = "[{conf.low}, {conf.high}]",
             notes = paste0("Average \\textsc{ar} and \\textsc{car} to past FCPA targets and matched placebo firms ",
                            "per day. Standard errors of the mean reported in parentheses. P-values from a two-tailed test ",
                            "of difference from zero for the average against a standard normal distribution. ",
                            "Estimation window starts 30 days and ends 5 days before FCPA Executive Order. Market models estimated using ",
                            "the LASSO and individual S\\&P 500 constituents as predictors, selected using 5-fold cross validation. ",
                            "Columns 5 and 6 report the difference in means, respectively, between averages in columns 1 and 3, and those in columns 2 and 4.",
                            collapse = ""),
             title = "Varying CV folds of LASSO market models (5 folds) \\label{tab:rob_5f}",
             stars = c("*" = 0.05), 
             escape = FALSE) %>%
  group_tt(j = list("Past FCPA targets" = 2:3,
                    "Non-FCPA targets" = 4:5,
                    "Difference-in-means" = 6:7)) %>%
  group_tt(i = list("Pre-event:" = 1,
                    "Post-event:" = 11)) %>%
  style_tt(i = 21, line_color = "white", line_width = 0.1, line = "t") %>%
  style_tt(i = 22, line_color = "black", line_width = 0.05, line = "b") %>%
  theme_tt("resize", width = .9) %>%
  theme_tt("placement", latex_float = "!htbp") %>%
  save_tt("tables/table_H2.html", overwrite = TRUE)

# Table H.3: Varying CV folds of LASSO market models (3 folds) ----
est <- return_daily_avg(data = stocks, abn_ret = "abn_chg_30d3f", cum_abn_ret = "car_30d3f", stratum = "FCPA_sample") %>%
  mutate(date = format(date, format = "%a, %b %d %Y")) %>%
  rename("term" = "date")

mod_ar1 <- list(tidy = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car1 <- list(tidy = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar0 <- list(tidy = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car0 <- list(tidy = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar_diff <- list(tidy = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      select(-FCPA_sample, -dv),
                    glance = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      filter(term == "Mon, Feb 10 2025") %>%
                      select(N) %>%
                      rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car_diff <- list(tidy = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       select(-FCPA_sample, -dv),
                     glance = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       filter(term == "Mon, Feb 10 2025") %>%
                       select(N) %>%
                       rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

modelsummary(list("(1) \\textsc{ar}" = mod_ar1,
                  "(2) \\textsc{car}" = mod_car1,
                  "(3) \\textsc{ar}" = mod_ar0,
                  "(4) \\textsc{car}" = mod_car0,
                  "(5) \\textsc{ar}" = mod_ar_diff,
                  "(6) \\textsc{car}" = mod_car_diff),
             # statistic = "[{conf.low}, {conf.high}]",
             notes = paste0("Average \\textsc{ar} and \\textsc{car} to past FCPA targets and matched placebo firms ",
                            "per day. Standard errors of the mean reported in parentheses. P-values from a two-tailed test ",
                            "of difference from zero for the average against a standard normal distribution. ",
                            "Estimation window starts 30 days and ends 5 days before FCPA Executive Order. Market models estimated using ",
                            "the LASSO and individual S\\&P 500 constituents as predictors, selected using 3-fold cross validation. ",
                            "Columns 5 and 6 report the difference in means, respectively, between averages in columns 1 and 3, and those in columns 2 and 4.",
                            collapse = ""),
             title = "Varying CV folds of LASSO market models (3 folds) \\label{tab:rob_3f}",
             stars = c("*" = 0.05), 
             escape = FALSE) %>%
  group_tt(j = list("Past FCPA targets" = 2:3,
                    "Non-FCPA targets" = 4:5,
                    "Difference-in-means" = 6:7)) %>%
  group_tt(i = list("Pre-event:" = 1,
                    "Post-event:" = 11)) %>%
  style_tt(i = 21, line_color = "white", line_width = 0.1, line = "t") %>%
  style_tt(i = 22, line_color = "black", line_width = 0.05, line = "b") %>%
  theme_tt("resize", width = .9) %>%
  theme_tt("placement", latex_float = "!htbp") %>%
  save_tt("tables/table_H3.html", overwrite = TRUE)

# Table H.4: Varying estimation window length of LASSO market models (start 90 days pre-Executive Order) ----
est <- return_daily_avg(data = stocks, abn_ret = "abn_chg_90d15f", cum_abn_ret = "car_90d15f", stratum = "FCPA_sample") %>%
  mutate(date = format(date, format = "%a, %b %d %Y")) %>%
  rename("term" = "date")

mod_ar1 <- list(tidy = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car1 <- list(tidy = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar0 <- list(tidy = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car0 <- list(tidy = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar_diff <- list(tidy = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      select(-FCPA_sample, -dv),
                    glance = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      filter(term == "Mon, Feb 10 2025") %>%
                      select(N) %>%
                      rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car_diff <- list(tidy = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       select(-FCPA_sample, -dv),
                     glance = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       filter(term == "Mon, Feb 10 2025") %>%
                       select(N) %>%
                       rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

modelsummary(list("(1) \\textsc{ar}" = mod_ar1,
                  "(2) \\textsc{car}" = mod_car1,
                  "(3) \\textsc{ar}" = mod_ar0,
                  "(4) \\textsc{car}" = mod_car0,
                  "(5) \\textsc{ar}" = mod_ar_diff,
                  "(6) \\textsc{car}" = mod_car_diff),
             # statistic = "[{conf.low}, {conf.high}]",
             notes = paste0("Average \\textsc{ar} and \\textsc{car} to past FCPA targets and matched placebo firms ",
                            "per day. Standard errors of the mean reported in parentheses. P-values from a two-tailed test ",
                            "of difference from zero for the average against a standard normal distribution. ",
                            "Estimation window starts 90 days and ends 5 days before FCPA Executive Order. Market models estimated using ",
                            "the LASSO and individual S\\&P 500 constituents as predictors, selected using 15-fold cross validation. ",
                            "Columns 5 and 6 report the difference in means, respectively, between averages in columns 1 and 3, and those in columns 2 and 4.",
                            collapse = ""),
             title = "Varying estimation window length of LASSO market models (start 90 days pre-Executive Order) \\label{tab:rob_90d}",
             stars = c("*" = 0.05), 
             escape = FALSE) %>%
  group_tt(j = list("Past FCPA targets" = 2:3,
                    "Non-FCPA targets" = 4:5,
                    "Difference-in-means" = 6:7)) %>%
  group_tt(i = list("Pre-event:" = 1,
                    "Post-event:" = 11)) %>%
  style_tt(i = 21, line_color = "white", line_width = 0.1, line = "t") %>%
  style_tt(i = 22, line_color = "black", line_width = 0.05, line = "b") %>%
  theme_tt("resize", width = .9) %>%
  theme_tt("placement", latex_float = "!htbp") %>%
  save_tt("tables/table_H4.html", overwrite = TRUE)

# Table H.5: Varying estimation window length of LASSO market models (start 180 days pre-Executive Order) ----
est <- return_daily_avg(data = stocks, abn_ret = "abn_chg_180d15f", cum_abn_ret = "car_180d15f", stratum = "FCPA_sample") %>%
  mutate(date = format(date, format = "%a, %b %d %Y")) %>%
  rename("term" = "date")

mod_ar1 <- list(tidy = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car1 <- list(tidy = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar0 <- list(tidy = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car0 <- list(tidy = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar_diff <- list(tidy = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      select(-FCPA_sample, -dv),
                    glance = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      filter(term == "Mon, Feb 10 2025") %>%
                      select(N) %>%
                      rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car_diff <- list(tidy = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       select(-FCPA_sample, -dv),
                     glance = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       filter(term == "Mon, Feb 10 2025") %>%
                       select(N) %>%
                       rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

modelsummary(list("(1) \\textsc{ar}" = mod_ar1,
                  "(2) \\textsc{car}" = mod_car1,
                  "(3) \\textsc{ar}" = mod_ar0,
                  "(4) \\textsc{car}" = mod_car0,
                  "(5) \\textsc{ar}" = mod_ar_diff,
                  "(6) \\textsc{car}" = mod_car_diff),
             # statistic = "[{conf.low}, {conf.high}]",
             notes = paste0("Average \\textsc{ar} and \\textsc{car} to past FCPA targets and matched placebo firms ",
                            "per day. Standard errors of the mean reported in parentheses. P-values from a two-tailed test ",
                            "of difference from zero for the average against a standard normal distribution. ",
                            "Estimation window starts 180 days and ends 5 days before FCPA Executive Order. Market models estimated using ",
                            "the LASSO and individual S\\&P 500 constituents as predictors, selected using 15-fold cross validation. ",
                            "Columns 5 and 6 report the difference in means, respectively, between averages in columns 1 and 3, and those in columns 2 and 4.",
                            collapse = ""),
             title = "Varying estimation window length of LASSO market models (start 180 days pre-Executive Order) \\label{tab:rob_180d}",
             stars = c("*" = 0.05), 
             escape = FALSE) %>%
  group_tt(j = list("Past FCPA targets" = 2:3,
                    "Non-FCPA targets" = 4:5,
                    "Difference-in-means" = 6:7)) %>%
  group_tt(i = list("Pre-event:" = 1,
                    "Post-event:" = 11)) %>%
  style_tt(i = 21, line_color = "white", line_width = 0.1, line = "t") %>%
  style_tt(i = 22, line_color = "black", line_width = 0.05, line = "b") %>%
  theme_tt("resize", width = .9) %>%
  theme_tt("placement", latex_float = "!htbp") %>%
  save_tt("tables/table_H5.html", overwrite = TRUE)

# Table H.6: Using OLS for estimation of market models ----
est <- return_daily_avg(data = stocks, abn_ret = "abn_chg_180dols", cum_abn_ret = "car_180dols", stratum = "FCPA_sample") %>%
  mutate(date = format(date, format = "%a, %b %d %Y")) %>%
  rename("term" = "date")

mod_ar1 <- list(tidy = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car1 <- list(tidy = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar0 <- list(tidy = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car0 <- list(tidy = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar_diff <- list(tidy = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      select(-FCPA_sample, -dv),
                    glance = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      filter(term == "Mon, Feb 10 2025") %>%
                      select(N) %>%
                      rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car_diff <- list(tidy = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       select(-FCPA_sample, -dv),
                     glance = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       filter(term == "Mon, Feb 10 2025") %>%
                       select(N) %>%
                       rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

modelsummary(list("(1) \\textsc{ar}" = mod_ar1,
                  "(2) \\textsc{car}" = mod_car1,
                  "(3) \\textsc{ar}" = mod_ar0,
                  "(4) \\textsc{car}" = mod_car0,
                  "(5) \\textsc{ar}" = mod_ar_diff,
                  "(6) \\textsc{car}" = mod_car_diff),
             # statistic = "[{conf.low}, {conf.high}]",
             notes = paste0("Average \\textsc{ar} and \\textsc{car} to past FCPA targets ",
                            "per day. Standard errors of the mean reported in parentheses. P-values from a two-tailed test ",
                            "of difference from zero for the average against a standard normal distribution. ",
                            "Estimation window starts 180 days before FCPA Executive Order and ends 5 days before it. Market models estimated using ",
                            "OLS and aggregate S\\&P 500 index as predictor. ",
                            "Columns 5 and 6 report the difference in means, respectively, between averages in columns 1 and 3, and those in columns 2 and 4.",
                            collapse = ""),
             title = "Using OLS for estimation of market models \\label{tab:rob_ols}",
             stars = c("*" = 0.05), 
             escape = FALSE) %>%
  group_tt(j = list("Past FCPA targets" = 2:3,
                    "Non-FCPA targets" = 4:5,
                    "Difference-in-means" = 6:7)) %>%
  group_tt(i = list("Pre-event:" = 1,
                    "Post-event:" = 11)) %>%
  style_tt(i = 21, line_color = "white", line_width = 0.1, line = "t") %>%
  style_tt(i = 22, line_color = "black", line_width = 0.05, line = "b") %>%
  theme_tt("resize", width = .9) %>%
  theme_tt("placement", latex_float = "!htbp") %>%
  save_tt("tables/table_H6.html", overwrite = TRUE)

# Table H.7: Estimation windows end one day before Executive Order ----
est <- return_daily_avg(data = stocks, abn_ret = "abn_chg_var", cum_abn_ret = "car_var", stratum = "FCPA_sample") %>%
  mutate(date = format(date, format = "%a, %b %d %Y")) %>%
  rename("term" = "date")

mod_ar1 <- list(tidy = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "1" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car1 <- list(tidy = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "1" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar0 <- list(tidy = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  select(-FCPA_sample, -dv),
                glance = est %>%
                  filter(FCPA_sample == "0" &
                           dv == "ar") %>%
                  filter(term == "Mon, Feb 10 2025") %>%
                  select(N) %>%
                  rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car0 <- list(tidy = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   select(-FCPA_sample, -dv),
                 glance = est %>%
                   filter(FCPA_sample == "0" &
                            dv == "car") %>%
                   filter(term == "Mon, Feb 10 2025") %>%
                   select(N) %>%
                   rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_ar_diff <- list(tidy = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      select(-FCPA_sample, -dv),
                    glance = est %>%
                      filter(FCPA_sample == "diff" &
                               dv == "ar") %>%
                      filter(term == "Mon, Feb 10 2025") %>%
                      select(N) %>%
                      rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

mod_car_diff <- list(tidy = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       select(-FCPA_sample, -dv),
                     glance = est %>%
                       filter(FCPA_sample == "diff" &
                                dv == "car") %>%
                       filter(term == "Mon, Feb 10 2025") %>%
                       select(N) %>%
                       rename("N of firms" = "N")) %>%
  `class<-`("modelsummary_list")

modelsummary(list("(1) \\textsc{ar}" = mod_ar1,
                  "(2) \\textsc{car}" = mod_car1,
                  "(3) \\textsc{ar}" = mod_ar0,
                  "(4) \\textsc{car}" = mod_car0,
                  "(5) \\textsc{ar}" = mod_ar_diff,
                  "(6) \\textsc{car}" = mod_car_diff),
             # statistic = "[{conf.low}, {conf.high}]",
             notes = paste0("Average \\textsc{ar} and \\textsc{car} to past FCPA targets ",
                            "per day. Standard errors of the mean reported in parentheses. P-values from a two-tailed test ",
                            "of difference from zero for the average against a standard normal distribution. ",
                            "Estimation window starts 30 days before FCPA Executive Order and ends 1 day before it. Market models estimated using ",
                            "LASSO and individual S\\&P 500 constituents as predictor, selected using 15-fold cross validation. ",
                            "Columns 5 and 6 report the difference in means, respectively, between averages in columns 1 and 3, and those in columns 2 and 4.",
                            collapse = ""),
             title = "Estimation windows end one day before Executive Order \\label{tab:rob_var}",
             stars = c("*" = 0.05), 
             escape = FALSE) %>%
  group_tt(j = list("Past FCPA targets" = 2:3,
                    "Non-FCPA targets" = 4:5,
                    "Difference-in-means" = 6:7)) %>%
  group_tt(i = list("Pre-event:" = 1,
                    "Post-event:" = 11)) %>%
  style_tt(i = 21, line_color = "white", line_width = 0.1, line = "t") %>%
  style_tt(i = 22, line_color = "black", line_width = 0.05, line = "b") %>%
  theme_tt("resize", width = .9) %>%
  theme_tt("placement", latex_float = "!htbp") %>%
  save_tt("tables/table_H7.html", overwrite = TRUE)

#====# The End #====#